package org.example.POJO.game;

import org.example.Page.GamePanel;

import java.awt.*;

public class Pao extends Chess {
    public Pao(int camp, Point p) {
        super("pao", camp, p);
    }
    public Pao(int camp,int px)
    {
        this(camp,new Point(px,3));
    }
    @Override
    public boolean isAbleMove(Point tp, GamePanel gamePanel) {
        Chess c = gamePanel.getChessByP(tp);
        if (c != null) {
            if (c.getCamp() != this.camp) {
                //吃子
                return isLine(tp) > 1 && getCount(tp, gamePanel) == 1;
            }
        } else {
            //移动
            return isLine(tp) > 1 && getCount(tp, gamePanel) == 0;
        }

        return false;
    }
}
